'''
测试logging模块，打印异常堆栈信息
'''

import logging

logging.basicConfig(level=logging.INFO,format='%(asctime)s - %(filename)s[line:%(lineno)d] - %(levelname)s: %(message)s')
logger = logging.getLogger(__name__)


def abs2(a):
    try :
        a = abs(a)
    except Exception :
        logger.info("获取绝对值失败。",exc_info=True)
        return
    logger.info("获取绝对值成功")
    return a

a = abs2('1a')
print("绝对值：|-1| = ",a)
